<template>
  <div class="common-setting slim-view normal-shadow">
    <el-form :model="settingObject">
      <el-form-item label="菜单样式">
        <el-switch v-model="menuPostion" inline-prompt :active-value="'top'" :inactive-value="'left'" active-text="顶部" inactive-text="左侧" @change="menuPositionChaged" />
      </el-form-item>
    </el-form>
  </div>
</template>

<script setup lang="ts">
import { computed } from 'vue'
import { userSettingsStore } from '../stores/settings'

// ts写法
withDefaults(
  defineProps<{
    msg?: string // 是否必传
  }>(),
  {
    msg: '默认值'
  }
)

const settingStore = userSettingsStore()

const { menuPostion } = storeToRefs(settingStore)

const settingObject = ref({
  menuPosition: 'top' as 'top' | 'left'
})
//@ts-ignore
let mul = computed(() => {
  return ''
})
//@ts-ignore
const asd = () => {
  console.debug()
  return ''
}

const menuPositionChaged = (val: 'top' | 'left') => {
  console.log(val)
  settingStore.setMenuPostion(val)
}
</script>

<style scoped lang="scss">
.common-setting {
  // width: calc(100% - 40px);
  height: 100%;
  box-sizing: border-box;
  margin: 0 20px;
}
</style>
